POV-Ray : Newsgroups : povray.off-topic : Ok, someone explain this in English... (exploring quaternions) : Re: Ok, someone explain this in English... (exploring quaternions) Server Time
7 Sep 2024 09:20:33 EDT (-0400)
  Re: Ok, someone explain this in English... (exploring quaternions)  
From: scott
Date: 30 Jun 2008 05:05:00
Message: <4868a1bc@news.povray.org>
> Well. Was more wondering if there was some "sane" way to handle them
> without having the convert them at all. Basically, you do something
> like:
>
> a = llGetRot(me);
> b = llGetLookAt();
>
> then either do 'llSetRot(a*b);' or 'llSetRot(b);', depending on if you
> want to try to preserve "any" of the original orientation. The problem,
> of course, is simply that 'b' is not oriented to the same up/down or
> even top/bottom as 'a' in the first place. So, you either have to delete
> one of the angles, then apply, or convert to Euler, switch them around,
> then convert back to Quaternian, and *then* apply. The first method
> seems to be impractical, or impossible, take you pick, due to how the
> the stuff works. Its seriously annoying.

The 2nd method you propose seems feasible.

I would rotate the "forward" direction of your model (eg the axis vector 
(1,0,0)) by the quaternion "a".  Maybe your script language lets you do this 
just with a *, if not you need to look up how to rotate a vector by a 
quaternion - it's not hard or expensive.

Then with this vNew, you can work out the two rotation angles, limit them to 
whatever ranges you see fit, then create a new quaternion from these angles.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.